using System;
using System.Collections;
using System.DirectoryServices;

namespace BEGDC.CC.Entity
{
	#region CATBranchEmployee

	/// <summary>
	/// CATBranchEmployee object for NHibernate mapped table 'CATBranchEmployee'.
	/// </summary>
	[Serializable]
	public class CATBranchEmployee : System.IComparable
		{
		#region Member Variables
		
		protected int _id;
		protected string _type;
		protected Employee _employee;
		protected DicItem _cATBranch;
		protected static String _sortExpression = "Id";
		protected static SortDirection _sortDirection = SortDirection.Ascending;

		#endregion

		#region Constructors

		public CATBranchEmployee() { }

		public CATBranchEmployee( string type, Employee employee, DicItem cATBranch )
		{
			this._type = type;
			this._employee = employee;
			this._cATBranch = cATBranch;
		}

		#endregion

		#region Public Properties

		public int Id
		{
			get {return _id;}
			set {_id = value;}
		}

		public string Type
		{
			get { return _type; }
			set
			{
				if ( value != null && value.Length > 20)
					throw new ArgumentOutOfRangeException("Invalid value for Type", value, value.ToString());
				_type = value;
			}
		}

		public Employee Employee
		{
			get { return _employee; }
			set { _employee = value; }
		}

		public DicItem CATBranch
		{
			get { return _cATBranch; }
			set { _cATBranch = value; }
		}

        public static String SortExpression
        {
            get { return _sortExpression; }
            set { _sortExpression = value; }
        }

        public static SortDirection SortDirection
        {
            get { return _sortDirection; }
            set { _sortDirection = value; }
        }
		#endregion
		
        #region IComparable Methods
        public int CompareTo(object obj)
        {
			if (!(obj is CATBranchEmployee))
				throw new InvalidCastException("This object is not of type CATBranchEmployee");
			
			int relativeValue;
			switch (SortExpression)
			{
				case "Id":
					relativeValue = this.Id.CompareTo(((CATBranchEmployee)obj).Id);
					break;
				case "Type":
					relativeValue = this.Type.CompareTo(((CATBranchEmployee)obj).Type);
					break;
                default:
                    goto case "Id";
			}
            if (CATBranchEmployee.SortDirection == SortDirection.Ascending)
				relativeValue *= -1;
			return relativeValue;
		}
		#endregion
	}

	#endregion
}
